/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package ekahau.positioning.client.ui.imageviewer;

import java.util.Vector;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import ekahau.positioning.client.ui.imageviewer.IUserSelectionChangeListener;
import ekahau.positioning.client.ui.navigator.NavigationView;
import ekahau.positioning.client.ui.navigator.NavigationView.TagInfo;



/**
 * This ImageView class shows how to use SWTImageCanvas to 
 * manipulate images. 
 * <p>
 * To facilitate the usage, you should setFocus to the canvas
 * at the beginning, and call the dispose at the end.
 * <p>
 * @author Chengdong Li: cli4@uky.edu
 * @see uky.article.imageviewer.SWTImageCanvas
 */

public class ImageView extends ViewPart implements IUserSelectionChangeListener{
	
	public SWTImageCanvas imageCanvas;
	private TagInfo curInfo ;
	public static final String ID = "LTUClient.DetailView";
	/**
	 * The constructor.
	 */
	public ImageView() {
	}
	
	/**
	 * Create the GUI.
	 * @param frame The Composite handle of parent
	 */
	public void createPartControl(Composite frame) {
		
		imageCanvas=new SWTImageCanvas(frame);
		NavigationView view = (NavigationView)getSite().getWorkbenchWindow().getActivePage().findView(NavigationView.ID);
		view.setSelectionListener(this);
		
	}

	/**
	 * Called when we must grab focus.
	 * @see org.eclipse.ui.part.ViewPart#setFocus
	 */
	public void setFocus() {
		imageCanvas.setFocus();
	}

	/**
	 * Called when the View is to be disposed
	 */
	public void dispose() {
		imageCanvas.dispose();
		super.dispose();
	}

	@Override
	public void navigatorSelectionChanged(TagInfo info, Vector<Point> tracker) {
		curInfo = info ;
		imageCanvas.setPoint(tracker.toArray(new Point[tracker.size()]));
		
	}

	@Override
	public void navigatorSelectionChanged(TagInfo[] info,
			Vector<Point>[] tracker) {
		imageCanvas.setPoint(tracker);
		
	}

}